package cq.com.cn.servlet;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import cq.com.cn.model.BooksModel;
import cq.com.cn.model.UserModel;
import cq.com.cn.service.BooksService;
import cq.com.cn.service.UserService;
import cq.com.cn.utils.AjaxUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/query/querybookById.do")
public class QueryBookWithIdServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取书籍类型
        String id=req.getParameter("id");
        //调用业务层
        BooksService booksService=new BooksService();
        BooksModel book = booksService.selectBookById(id);
        //返回数据给前端
        req.setAttribute("book",book);
        req.getRequestDispatcher("/view/bookdetails.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
